package com.chagee.channel.server.config;

import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.region.Region;

@Configuration
public class COSConfig {

    @Value("${qcloud.cos.accessId}")
    private String QCCLOUD_SECRETID;
    @Value("${qcloud.cos.accessSecret}")
    private String QCCLOUD_SECRETKEY;
    @Value("${qcloud.cos.id}")
    private String QCCLOUD_ID;
    @Value("${qcloud.cos.bucket}")
    private String COS_BUCKET;
    @Value("${qcloud.cos.region}")
    private String COS_REGION;



    @Bean
    public COSClient cosClient() {
        ClientConfig clientConfig = new ClientConfig(new Region(COS_REGION));
        COSCredentials cred = new BasicCOSCredentials(QCCLOUD_SECRETID, QCCLOUD_SECRETKEY);
        return new COSClient(cred,clientConfig);
    }
}
